package com.luowenbo.shortlink.separation.aspect;


import com.luowenbo.shortlink.separation.DynamicDataSource;
import com.luowenbo.shortlink.separation.annotation.HotCold;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/***
 * @Author luowenbo
 */
@Component
@Aspect
public class DynamicDataSourceAspect implements Ordered {

    // 前置
    @Before("within(com.luowenbo.shortlink.separation.service.impl.*) && @annotation(hotCold)")
    public void before(JoinPoint point, HotCold hotCold){
        String name = hotCold.value();
        DynamicDataSource.name.set(name);
        System.out.println(name);
    }

    @Override
    public int getOrder()    {
        return 0;
    }

    // 环绕通知
}
